<template>
    <div>
        <div>
            <el-form :inline="true" label-width="100" :model="formInline"  class="demo-form-inline">
                <el-form-item label="交接单号">
                    <el-input class="input-width" v-model="formInline.deliveryPlanCode" size="mini" placeholder="交接单号"></el-input>
                </el-form-item>
                <el-form-item label="条码">
                    <el-input class="input-width" v-model="formInline.barcode" size="mini" placeholder="条码"></el-input>
                </el-form-item>
                <el-form-item label="物料图号">
                    <el-input class="input-width" v-model="formInline.itemCode" size="mini" placeholder="物料图号"></el-input>
                </el-form-item>
                <el-form-item label="成品型号">
                    <el-input class="input-width" v-model="formInline.mProductNumber" size="mini" placeholder="成品型号"></el-input>
                </el-form-item>
                <el-form-item label="质量编号">
                    <el-input class="input-width" v-model="formInline.qualityCode" size="mini" placeholder="质量编号"></el-input>
                </el-form-item>
                <el-form-item label="分配状态">
                    <el-select class="input-width" v-model="formInline.dealVal" size="mini" placeholder="任务状态">
                        <el-option v-for="task in taskoptions" :key="task.value" :label="task.label" :value="task.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="分配日期">
                    <el-date-picker style="width:140px" value-format="yyyy-MM-dd" v-model="formInline.startTime" size="mini" type="date" placeholder="开始日期"></el-date-picker>到
                    <el-date-picker style="width:140px" value-format="yyyy-MM-dd" v-model="formInline.endTime" size="mini" type="date" placeholder="结束日期"></el-date-picker>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" size="mini" @click="doQuery">查询</el-button>
                    <el-button type="primary" size="mini" @click="doReset">重置</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div>
            <el-table :data="tableData" height="550"  row-key="id" :load="load" lazy default-expand-all 
                :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
                <el-table-column prop="itemCode" label="图号" sortable  width="250"> </el-table-column>
                <el-table-column prop="mProductNumber" label="成品型号" sortable  width="120"> </el-table-column>
                <el-table-column prop="qualityCode" label="质量编号"   width="120"> </el-table-column>
                <el-table-column  prop="itemQty" label="数量"  > </el-table-column>
                <el-table-column  prop="workbinCode" label="缓存箱" width="180"  > </el-table-column>
                <el-table-column  prop="barcode" label="条码" width="360"  > </el-table-column>
                <el-table-column  prop="createDate" label="日期" sortable > </el-table-column>
            </el-table>
            <div>
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="page.currentPage"
                :page-sizes="[50,100, 200, 300, 400]" :page-size="page.pageSize"  layout="total, sizes, prev, pager, next" :total="page.total">
                </el-pagination>
            </div>
        </div>
    </div>
</template>
<script>
import request from "@/utils/request.js";
export default{
    name:"workMaterialQuery",
    data(){
        return {
            formInline:{
                itemCode:"",
                mProductNumber:"",
                qualityCode:"",
                dealVal:"",
                deliveryPlanCode:"",
                barcode:"",
                startTime:"",
                endTime:""
            },
            taskoptions:[{
                label:"请选择",
                value:"0"
            },{
                label:"已完成接收",
                value:"Y"
            },{
                label:"未完成接收",
                value:"N"
            }],
            page:{
                total:1,
                pageSize:50,
                currentPage:1
            },
            tableData:[]
        }
    },
    methods:{
        handleSelectionChange(){

        },
        handleSizeChange(val){
            this.page.pageSize = val;
        },
        handleCurrentChange(val){
            this.page.currentPage = val;
            this.$options.methods.doQuery.bind(this)();
        },
        //加载展开的树
        load(tree, treeNode, resolve){
            var that = this;
            request.post("/synthesizeQueryRest/queryWorkbinChild",{"queryParam":this.formInline,"tree":tree}).then((res)=>{
                console.log("res",res);
                resolve(res.data);
            });
        },
        //查询
        doQuery(){
            var that = this;
            request.post("/synthesizeQueryRest/queryWorkbinParent",{"page":this.page,"queryParam":this.formInline}).then((res)=>{
                console.log(res);
                that.tableData = res.data.list;
                that.page.total = res.data.total;
            });
        },
        //重置
        doReset(){
            Object.assign(this.formInline,this.$options.data().formInline);
        }
    }
}
</script>
<style>

</style>